package com.smart.auth.dto;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author zhangwei
 */
@Data
public class MemberDto implements UserDetails {

    private String username;
    private String password;
    private Long memberId;
    /**
     * 逻辑删除
     */
    private Integer status;

    /**
     * 权限信息
     *
     * @return
     */
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return new ArrayList<>();
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    /**
     * 1 表示正常
     * 0 表示删除
     *
     * @return
     */
    @Override
    public boolean isEnabled() {
        return this.status > 0;
    }
}
